package com.mktneutral.jobs;

import org.quartz.JobBuilder;
import org.quartz.JobDetail;
import org.quartz.SchedulerException;
import org.quartz.SimpleScheduleBuilder;
import org.quartz.TriggerBuilder;
import org.quartz.Trigger;
import org.quartz.impl.StdSchedulerFactory;
import org.quartz.Scheduler;

public class QuartzScheduler {
   private static final int INTERVAL = 1800; //Execute the jobs every half hour.	
   
   public static void main(String[] args) {
	   JobDetail job = JobBuilder.newJob(WebLogins.class).withIdentity("WebLogins").build();
	   
	   Trigger trigger = TriggerBuilder.newTrigger()
	    .withIdentity("webLoginsTrigger","Group1")
	    .withSchedule(SimpleScheduleBuilder.simpleSchedule().withIntervalInSeconds(INTERVAL).repeatForever())
	    .build();
	   
	   try {
		   Scheduler scheduler = new StdSchedulerFactory().getScheduler();
		   scheduler.start();;
		   scheduler.scheduleJob(job, trigger);
	   } catch ( SchedulerException se ) {
		   se.printStackTrace();
	   }
   }
}
